A=[0,1,5;0.5,0,0;0,0.25,0];
population=[[1;0;0],zeros(3,100)];
lambda=zeros(1,100);

for n=1:100
    population(:,n+1)=A*population(:,n);
    lambda(n)=sum(population(:,n+1))/sum(population(:,n));
end;

figure;
plot((1:100),lambda);
xlabel('time');
ylabel('total(n+1)/total(n)');
legend('\lambda');

disp('The lambda calculated by Euler-Lotka equation is');
disp(fzero(@EG2_7_ELEquation,1));